#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
using webapp4U.DAL;
#endregion


namespace webapp4U.BOL
{
	 public class ShoppingCart
	 {
	     #region Member Variables

	     private Int32 _shoppingCartID;

	     private DateTime _addedDate;

	     private String _userID;

	     private Int32 _productID;

	     private String _title;

	     private String _sKU;

	     private Decimal _unitPrice;

	     private Int32 _quantity;

	     private Decimal _subtotal;

	     #endregion



	     #region Public Properties

	     public Int32 ShoppingCartID
	     {
		     get { return _shoppingCartID; }
		     set { _shoppingCartID = value; }
	     }

	     public DateTime AddedDate
	     {
		     get { return _addedDate; }
		     set { _addedDate = value; }
	     }

	     public String UserID
	     {
		     get { return _userID; }
		     set { _userID = value; }
	     }

	     public Int32 ProductID
	     {
		     get { return _productID; }
		     set { _productID = value; }
	     }

	     public String Title
	     {
		     get { return _title; }
		     set { _title = value; }
	     }

	     public String SKU
	     {
		     get { return _sKU; }
		     set { _sKU = value; }
	     }

	     public Decimal UnitPrice
	     {
		     get { return _unitPrice; }
		     set { _unitPrice = value; }
	     }

	     public Int32 Quantity
	     {
		     get { return _quantity; }
		     set { _quantity = value; }
	     }

	     public Decimal Subtotal
	     {
		     get { return _subtotal; }
		     set { _subtotal = value; }
	     }

	     #endregion

	     #region public static Methods

         public static Decimal GetSubTotalShoppingCart()
         {
             try
             {
                 ShoppingCartDAL db = new ShoppingCartDAL();
                 return db.GetSubTotalShoppingCart(Globals.CurrentUserID);
             }
             catch { return 0; }
         }

	     public static int Insert(ShoppingCart obj)
	     {
		     ShoppingCartDAL db = new ShoppingCartDAL();
             if (db.CheckShoppingCart(obj) == true)
             {
                 db.UpdateQuantity(obj);
                 return 10;
             }
             else
    		     return db.Insert(obj);
	     }


	     public static bool Update(ShoppingCart obj)
	     {
		     ShoppingCartDAL db = new ShoppingCartDAL();
		     return db.Update(obj);
	     }

         public static bool Delete(Int32 ProductID)
	     {
		     ShoppingCartDAL db = new ShoppingCartDAL();
             return db.Delete(ProductID); 
	     }

	     public static ShoppingCart GetShoppingCartByID(Int32 ShoppingCartID)
	     {
		     ShoppingCartDAL db = new ShoppingCartDAL();
		     return db.GetShoppingCartByID(ShoppingCartID);
	     }

	     //Get All ShoppingCart
	     public static List<ShoppingCart> GetAllShoppingCart(int PageIndex, int PageSize)
	     {
		     ShoppingCartDAL db = new ShoppingCartDAL();
		     return db.GetAllShoppingCart(PageIndex, PageSize);
	     }

	     // Get Count All records of Table  ShoppingCart
	     public static int GetCountShoppingCart()
	     {
		     ShoppingCartDAL db = new ShoppingCartDAL();
		     return db.GetCountShoppingCart();
	     }

	     // Get ShoppingCartByUserID
	     public static List<ShoppingCart> GetShoppingCartByUserID()
	     {
		     ShoppingCartDAL db = new ShoppingCartDAL();
		     return db.GetShoppingCartByUserID(Globals.CurrentUserID, 1, 100);
	     }

	     // Get ShoppingCartCountByUserID
	     public static int GetShoppingCartCountByUserID()
	     {
             try
             {
                 ShoppingCartDAL db = new ShoppingCartDAL();
                 return db.GetShoppingCartCountByUserID(Globals.CurrentUserID);
             }
             catch
             { return 0; }
	     }

	     #endregion
	 }
}
